<%@page import="modelo.Comment"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/estilos.css" type="text/css" charset="utf-8"/>
        <script src="js/jquery-1.4.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/formularioComentarios.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/cesta.js" type="text/javascript" charset="utf-8"></script>
    </head>
    <body>
        <div class="pagina">
            <%@ include file="cabecera.jsp"%>
            
            <div class="cuerpo">
                
                <%@include file="buscador.jsp"%>
                
                <div class="producto">
                    <div class="foto">
                        <img src="imgs/Productos/<%= request.getAttribute("id")%>.jpg" width="300">
                        <div class="clear"></div>
                        <input type="text" class="cantidad">
                        <input type="hidden" class="idProducto" value="<%= request.getAttribute("id") %>"> 
                        <a href="#" class="agregarCesta">Añadir a la cesta</a>
                        <div class="mensajeOk contenedor">
                            Producto añadido correctamente
                        </div>
                    </div>
                    <div class="descripcion contenedor">
                        <h1><%= request.getAttribute("name")%></h1>
                        <h2><%= request.getAttribute("price")%> </h2>
                        <div class="clear"></div>
                        <div class="corta">
                            <%= request.getAttribute("shortDescription") %>
                        </div>
                        <div class="larga">
                            <%= request.getAttribute("longDescription") %>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                
                <div class="comentarios contenedor">
                    <% ArrayList<Comment> commentList = (ArrayList) request.getAttribute("commentList");
                    if (commentList.size() == 0) {
                        %>
                        No hay comentarios. Añade uno.
                    <% }                        
                    for (Comment oneComment:commentList){%>
                    <div class="comentario">
                        <%= oneComment.getComment() %>                        
                    </div>
                    <% } %>                    
                    <a class="agregarComentario" href="#comentario">Agregar comentario</a>
                    <a name="comentario"></a>
                    <div class="formularioParaAgregarComentario">
                        <form method="POST" action="comments">
                            <input type="hidden" class="idProducto" name="idProducto" value=<%= request.getParameter("id") %>> 
                            <textarea name="comentario"></textarea>
                            <input type="submit" class="boton" value="Enviar comentario">
                        </form>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
            
            <%@ include file="pie.jsp"%>
            
        </div>
    </body>
</html>
